package com.weim.weim.util;/**
 * @author ：ju
 * @date ：Created 2024/7/8 5:30 PM
 * @description：生辰8字
 */

/**
 * @program: houlangss-server
 *
 * @description: 生辰8字
 *
 * @author: ju
 *
 * @create: 2024-07-08 17:30
 **/
public class BaziCalculator {

    // 简化版的天干地支
    private static final String[] TIANGAN = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
    private static final String[] DIZHI = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};

    // 这里仅作为示例，真实情况需要根据农历日期和节气来计算
    public static void calculateBazi(int lunarYear, int lunarMonth, int lunarDay, int lunarHour) {
        // 假设年份的天干地支
        String yearGan = TIANGAN[lunarYear % 10]; // 实际上需要复杂计算
        String yearZhi = DIZHI[(lunarYear - 3) % 12]; // 假设，同样需要复杂计算

        // 月份、日和时的天干地支计算通常更复杂，需要考虑节气等因素
        // 这里仅做简单示例
        String monthGan = TIANGAN[(lunarMonth - 1) % 10]; // 假设
        String monthZhi = DIZHI[(lunarMonth - 1) % 12]; // 假设

        String dayGan = TIANGAN[lunarDay % 10]; // 假设
        String dayZhi = DIZHI[(lunarDay - 1) % 12]; // 假设

        String hourGan = TIANGAN[lunarHour % 10]; // 假设，时辰转换为1-10或0-9
        String hourZhi = DIZHI[(lunarHour / 2) % 12]; // 假设，时辰转换为1-24需要调整

        // 输出八字
        System.out.println("生辰八字: " + yearGan + yearZhi + " " + monthGan + monthZhi + " " + dayGan + dayZhi + " " + hourGan + hourZhi);
    }


    public static void main(String[] args) {
        // 示例：假设的农历日期和时辰
        int lunarYear = 1990; // 农历年份
        int lunarMonth = 5; // 农历月份
        int lunarDay = 15; // 农历日期
        int lunarHour = 10; // 农历时辰（这里假设为10时辰，即上午9点到11点）

        calculateBazi(lunarYear, lunarMonth, lunarDay, lunarHour);
    }

}
